/**
 * 
 */
package com.jie.eclipse.pan.generator;

import com.jie.eclipse.pan.config.BasePageConfig;
import com.jie.eclipse.pan.data.BaseDataEntity;
import com.jie.eclipse.pan.xml.XMLNode;


/**
 * @author yanjie
 *
 */
public class PanGenerator extends BaseGenertor{
	@Override
	public StringBuffer GeneratorGridUIJspCode(BasePageConfig pageConfig) {
		return  this.GeneratorCodeByTp(getParamsByPageConfig(pageConfig), "base/grid/grid_ui.resource");
	}
	
	@Override
	public StringBuffer GeneratorGridBackEndJspCode(BasePageConfig pageConfig) {
		return  this.GeneratorCodeByTp(getParamsByPageConfig(pageConfig), "base/grid/grid_backend.resource");
	}
	
	@Override
	public StringBuffer GeneratorFormUIJspCode(BasePageConfig pageConfig) {
		return  this.GeneratorCodeByTp(getParamsByPageConfig(pageConfig), "base/form/form_ui.resource");
	}
	
	@Override
	public StringBuffer GeneratorFormBackEndJspCode(BasePageConfig pageConfig) {
		return  this.GeneratorCodeByTp(getParamsByPageConfig(pageConfig), "base/form/form_backend.resource");
	}
	
	
	/* 
	 * 导出表格模板配置
	 */
	@Override
	public StringBuffer GeneratorGridConfigXmlCode(BasePageConfig pageConfig) {
		StringBuffer code = new StringBuffer();
		XMLNode page = new XMLNode();
		this.getConfigHelper().exportGridConfig(page, pageConfig);
		code.append(XMLNode.Export(page));
		return code;
	}
	
	@Override
	public StringBuffer GeneratorFormConfigXmlCode(BasePageConfig pageConfig) {
		StringBuffer code = new StringBuffer();
		XMLNode page = new XMLNode();
		this.getConfigHelper().exportFormConfig(page, pageConfig);
		code.append(XMLNode.Export(page));
		return code;
	}
	
	/***
	
	@Override
	public StringBuffer GeneratorGridUIJspCode(BasePageConfig pageConfig) {
		StringBuffer code = new StringBuffer();
		code.append("<%@ page language=\"java\" contentType= \"text/html\" pageEncoding=\"UTF-8\"%>");
		code.append("\r\n<%@include file=\"/include/common/griduihead1.jsp\"%>");
		code.append("\r\n<%@include file=\"/include/common/griduihead2.jsp\"%>");
		code.append("\r\n<%");
		code.append("\r\n	page1.getPageTitle().setTitle(\""+pageConfig.getPageTitle()+"\");");
		code.append("\r\n%>");
		
		code.append("\r\n<jm:form>");
		code.append("\r\n<jm:layout postion=\"north\">");
		code.append("\r\n	"+this.GetToolbarCode(pageConfig));
		code.append("\r\n	<jm:pageTitle />");
		code.append("\r\n	");
		code.append("\r\n	<jm:error></jm:error>");
		code.append("\r\n</jm:layout>");
		code.append("\r\n");
		code.append("\r\n<jm:layout postion=\"center\">");
		code.append("\r\n</jm:layout>");
		code.append("\r\n");
		code.append("\r\n<jm:layout postion=\"south\"/>");
		code.append("\r\n</jm:form>");
		
		code.append("\r\n<jm:script><script type=\"text/javascript\" charset=\"UTF-8\">");
		code.append("\r\n</script></jm:script>");
		code.append("\r\n<%@include file=\"/include/common/griduiend.jsp\"%>");
		
		code.append("\r\n");
	}
	
	@Override
	public StringBuffer GeneratorFormUIJspCode(BasePageConfig pageConfig) {
		StringBuffer code = new StringBuffer();
		code.append("<%@ page language=\"java\" contentType= \"text/html\" pageEncoding=\"UTF-8\"%>");
		code.append("\r\n<%@include file=\"/include/common/formuihead1.jsp\"%>");
		code.append("\r\n<%@include file=\"/include/common/formuihead2.jsp\"%>");
		code.append("\r\n<%");
		code.append("\r\n	page1.getPageTitle().setTitle(\""+pageConfig.getPageTitle()+"\");");
		code.append("\r\n%>");
		
		code.append("\r\n<jm:form>");
		code.append("\r\n<jm:layout postion=\"north\">");
		code.append("\r\n	"+this.GetToolbarCode(pageConfig));
		code.append("\r\n	<jm:pageTitle />");
		code.append("\r\n</jm:layout>");
		code.append("\r\n");
		code.append("\r\n<jm:layout postion=\"center\">");
		code.append("\r\n	<jm:error></jm:error>");
		code.append("\r\n	");
		code.append("\r\n</jm:layout>");
		code.append("\r\n");
		code.append("\r\n<jm:layout postion=\"south\"/>");
		code.append("\r\n</jm:form>");
		
		code.append("\r\n<jm:script><script type=\"text/javascript\" charset=\"UTF-8\">");
		code.append("\r\n</script></jm:script>");
		code.append("\r\n<%@include file=\"/include/common/formuiend.jsp\"%>");
		
		code.append("\r\n");
		return code;
	}
	
	@Override
	public StringBuffer GeneratorGridBackEndJspCode(BasePageConfig pageConfig) {
		StringBuffer code = new StringBuffer();
		code.append("<%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\"%>");
		code.append("\r\n<%@include file=\"/include/common/gridbackhead.jsp\"%>");
		code.append("\r\n<%!");
		code.append("\r\nprivate class PageAction extends BaseAction{");
		code.append("\r\n	ResultSet rs = null;");
		code.append("\r\n	");
		code.append("\r\n	//准备action的环境变量 每次请次都会执行此方法 可在此方法中初如化一些变量");
		code.append("\r\n	protected void prepareActionEnv() throws Exception{");
		code.append("\r\n		");
		code.append("\r\n	}");
		code.append("\r\n	");
		code.append("\r\n	//加載頁面默認數據");
		code.append("\r\n	protected boolean onLoadDefault() throws Exception{");
		code.append("\r\n		return true ;");
		code.append("\r\n	}");
		code.append("\r\n	");
		code.append("\r\n	// 取出查询結果");
		code.append("\r\n	protected void onSearchRetrieveResult() throws Exception{");
		code.append("\r\n		");
		code.append("\r\n	}");
		code.append("\r\n");
		code.append("\r\n	//取出查詢語句");
		code.append("\r\n	protected String onSearchGetSql() throws Exception{");
		code.append("\r\n		StringBuilderEx whr =  new StringBuilderEx(\"1=1\");");
		code.append("\r\n		return whr.toString();");
		code.append("\r\n	}");
		code.append("\r\n");
		code.append("\r\n}");
		code.append("\r\n%>");
		code.append("\r\n<%@include file=\"/include/common/gridbackend.jsp\"%>");
		return code;
	}
	
	@Override
	public StringBuffer GeneratorFormBackEndJspCode(BasePageConfig pageConfig) {
		StringBuffer code = new StringBuffer();
		code.append("<%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\"%>");
		code.append("\r\n<%@include file=\"/include/common/formbackhead.jsp\"%>");
		code.append("\r\n<%!");
		code.append("\r\nprivate class PageAction extends BaseAction{");
		code.append("\r\n	ResultSet rs = null;");
		code.append("\r\n	");
		code.append("\r\n	//准备action的环境变量 每次请次都会执行此方法 可在此方法中初如化一些变量");
		code.append("\r\n	protected void prepareActionEnv() throws Exception{");
		code.append("\r\n		");
		code.append("\r\n	}");
		code.append("\r\n	");
		code.append("\r\n	//加載頁面默認數據");
		code.append("\r\n	protected boolean onLoadDefault() throws Exception{");
		code.append("\r\n		return true ;");
		code.append("\r\n	}");
		code.append("\r\n	");
		code.append("\r\n	// 取出查询結果");
		code.append("\r\n	protected void onSearchRetrieveResult() throws Exception{");
		code.append("\r\n		");
		code.append("\r\n	}");
		code.append("\r\n");
		code.append("\r\n	//取出查詢語句");
		code.append("\r\n	protected String onSearchGetSql() throws Exception{");
		code.append("\r\n		StringBuilderEx whr =  new StringBuilderEx(\"1=1\");");
		code.append("\r\n		return whr.toString();");
		code.append("\r\n	}");
		code.append("\r\n");
		code.append("\r\n	//处理储存驗證");
		code.append("\r\n	protected void onSaveValidate() throws Exception{");
		code.append("\r\n		");
		code.append("\r\n	}");
		code.append("\r\n	");
		code.append("\r\n	//執行儲存");
		code.append("\r\n	protected void doSave() throws Exception{");
		code.append("\r\n		");
		code.append("\r\n	}");
		code.append("\r\n	");
		code.append("\r\n}");
		code.append("\r\n%>");
		code.append("\r\n<%@include file=\"/include/common/formbackend.jsp\"%>");
		return code;
	}
	
	****/
	
	
	
	
}
